package com.unittec.drainage.sdk.auth.enums;

/**
 * @program: drainage-merger-parent
 * @description:
 * @author: djj
 * @create: 2019-06-28 11:53
 **/

import com.unittec.drainage.sdk.root.enums.BizCodeEnum;

import lombok.Getter;

/**
 * 日志级别定义
 */
@Getter
public enum BizErrorCode101 implements BizCodeEnum {
    // 应用权限相关10开始
    NO_APPLICATION("100011", "不存在该应用"), UNAVAILABLE_APPLICATION("100012", "应用为不可用状态"), ERROR_PASSWORD("100013", "密码错误"),
    NO_APPLICATION_FUNCTION("100014", "参数错误，不存在匹配的应用接口"), UNAUTHORIZED_APPLICATION("100015", "鉴权失败，请检查token值"),
    HAS_APPLICATION("100016", "该appCode已存在"), ERROR_APPLICATION("404", "接口报错"),

    // 限流相关20开始
    NO_LIMIT_CALL_ID("100020", "限流策略编码为空"), NO_LIMIT_CALL("100021", "没有对应的限流策略"), UPPER_LIMIT("100022", "调用达到上限值"),
    LIMIT_FUNCTION_UNAVAILABLE("100023", "接口状态不可用"), NO_LIMIT_FUNCTION("100024", "该配置没有对应的接口限流数据"),

    // 配置相关30开始
    NO_SETTING_OR_NOACTIVE("100031", "接口限流未配置"), NO_DEFAULT_SETTING_ID("100032", "无默认配置，请传入配置id"),
    UNAVAILABLE_SETTIN("100033", "配置不可用"), NO_SETTING_FUNCTION("100034", "参数错误，不存在匹配的配置接口"),

    // 接口相关40开始
    UNAVAILABLE_FUNCTION("100041", "接口未开通"), AUDITED_FUNCTION("100042", "接口待审核中"),

    // 用户
    HAS_USER("100050", "该用户名已存在"), NO_USER("100051", "不存在该用户"), NO_USERNAME("100052", "用户名为空"),
    DISABLE_USER("100053", "用户未激活"), NO_DEPART("100054", "不存在该机构"), LIST_ERROR("101004", "列表查询失败"),;

    private final String message;
    private final String code;

    BizErrorCode101(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static BizErrorCode101 getEnumByCode(String code) {
        BizErrorCode101[] bizErrorCode100s = values();
        for (BizErrorCode101 bizErrorCode100 : bizErrorCode100s) {
            if (bizErrorCode100.code().equals(code)) {
                return bizErrorCode100;
            }
        }
        return null;
    }

    public String code() {
        return this.code;
    }

}
